package com.ykq.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: qy174-mrcai
 * @description:
 * @author: 闫克起
 * @create: 2024-06-04 11:51
 **/
@Controller
@RequestMapping("/views/**")
public class PageController {
    /**
     * @param request 获取请求的url
     * @description: 对路径进行统一跳转
     * @create time: 2023/9/25 19:59
     */
    @RequestMapping
    public String toMain(HttpServletRequest request) {
        //接受请求地址
        String requestURI = request.getRequestURI();
        //判断是否是主页面
        if (requestURI.contains("main")) {
            return "main"; //WEB-INF/admin/main.jsp
        }
        requestURI=requestURI.substring(1);//去除第一个/
        String result = requestURI.substring(requestURI.indexOf("/")); //    views/user/list
        return result; //user/list  =====>WEB-INF/admin/user/list.jsp
    }
}



